Figure 2: Snapshot of the interactive map created using leaflet showing the neuropsychiatric hospitalisation SMRs in Cornwall LSOAs in 2011.

################ ploting interactive map of the SMR
pal <- colorNumeric(palette = "YlOrRd", domain = mapREPROJECTED$SMR)
labels <- sprintf("<strong> %s </strong> <br/> SMR: %s",
                  map1REPROJECTED$LSOA11NM, round(map1REPROJECTED$SMR, 2)) %>%
  lapply(htmltools::HTML)

twenty_11 <- leaflet(map1REPROJECTED) %>% addTiles() %>%
  addPolygons(color = "grey", weight = 1, fillColor = ~pal(SMR), fillOpacity = 0.5,
              highlightOptions = highlightOptions(weight = 4), label = labels,
              labelOptions = labelOptions(style = list("font-weight" = "normal",
                                                       padding = "3px 8px"),
                                          textsize = "15px",
                                          direction = "auto")) %>%
  addLegend(pal = pal, values = ~SMR, opacity = 0.5, title = "SMR",
            position = "bottomright")

twenty_11

Figure 12: Snapshot of the interactive map created using leaflet showing the neuropsychiatric hospitalisation RRs in Cornwall LSOAs in 2011.

############### PLOTTING a Interactive map of the RR

# specify the palette
pal <- colorNumeric(palette = "YlOrRd", domain = mapREPROJECTED$SMR)
# specify the labels
labels <- sprintf("<strong> %s </strong> <br/> SMR: %s <br/> Person per hectare: %s <br/> Green area (km2): %s <br/> 
                  Distance to Greenery (km): %s <br/> RR: %s (%s, %s)",
                  map1REPROJECTED$LSOA11NM, round(map1REPROJECTED$SMR, 2),
                  map1REPROJECTED$pop_density,
                  round(map1REPROJECTED$green_area, 2),
                  round(map1REPROJECTED$distance_to_green, 2),
                  round(map1REPROJECTED$RR, 2), 
                  round(map1REPROJECTED$LL, 2), round(map1REPROJECTED$UL, 2) ) %>%
  lapply(htmltools::HTML)

# apply final touches and now plot
rr_twenty11 <- leaflet(map1REPROJECTED) %>% addTiles() %>%
  addPolygons(color = "grey", weight = 1, fillColor = ~pal(RR), fillOpacity = 0.5,
              highlightOptions = highlightOptions(weight = 4), label = labels,
              labelOptions = labelOptions(style = list("font-weight" = "normal",
                                                       padding = "3px 8px"),
                                          textsize = "15px",
                                          direction = "auto")) %>%
  addLegend(pal = pal, values = ~RR, opacity = 0.5, title = "RR",
            position = "bottomright")

rr_twenty11